#include <bits/stdc++.h>
#include <string>
using namespace std;

int num[200] = {0};

int main()
{
    num['I'] = 1;
    num['V'] = 5;
    num['X'] = 10;
    num['L'] = 50;
    num['C'] = 100;
    num['D'] = 500;
    num['M'] = 1000;
    string str;
    cin >> str;
    int res = 0;
    for(int i=0;i<str.size()-1;i++){
        if(num[str[i]]>=num[str[i+1]]) res+=num[str[i]];
        else res-=num[str[i]];
    }
    res+=num[str[str.size()-1]];
    cout << res;
    return 0;
}
